/*
 * =====================================================================================
 *
 *       Filename:  fifo.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  06/30/15 18:16:49
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Andy (gk), andy_y_li@163.com
 *        Company:  RD
 *
 * =====================================================================================
 */

#ifndef _FIFO_H
#define _FIFO_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdbool.h>

#define FLAGS_OVERRUN 0x0001

typedef struct {
    char *buf;//
    int size; // The size of buffer
    int putP; // The position of next write
    int getP; // The position of next time to read
    char *dumpBuf; // Use in dump
}FIFO;

void fifo_init(FIFO *fifo, int size, char *buf);
bool fifo_put(FIFO *fifo, unsigned char data);
int fifo_get(FIFO *fifo);
int fifo_status(FIFO *fifo);
int fifo_free(FIFO *fifo);
bool fifo_add(FIFO *fifo, const char*buf, int length);
char *fifo_dump(FIFO *fifo);

#ifdef __cplusplus
}
#endif

#endif

